<?php
namespace app\common\command;

use app\common\CommandCron;
use app\http\Http;
use app\sys\model\Dict;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;
use think\Db;
use think\facade\Env;

class GwSite extends Command
{
    protected function configure()
    {
        $this->setName('gw_site')
            ->setDescription('官网数据拉取');
    }

    protected function execute(Input $input, Output $output)
    {
        $url = Env::get("GW.SITELIST");
        $data = Http::curlGet($url);
        $res = json_decode($data,true);
        if ($res["code"] != 200) $output->writeln("gw_site code false");
        Db::startTrans();
        try {
            CommandCron::site();
            Db::commit();
            $output->writeln("gw_site success");
        } catch (\Exception $e) {
            $output->writeln("gw_site false");
            Db::rollback();
        }
    }
}